package com.mceil.mceilbase.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.mceil.mylibrary.base.BaseFragment;

import java.util.List;

public class ViewPagerAdapter extends FragmentStateAdapter {
    private List<BaseFragment> mDatas;

    public ViewPagerAdapter(@NonNull FragmentActivity fragmentActivity, List<BaseFragment> mDatas) {
        super(fragmentActivity);
        this.mDatas = mDatas;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return mDatas.get(position);
    }

    @Override
    public int getItemCount() {
        return mDatas == null ? 0 : mDatas.size();
    }
}
